The present invention is generally related to the preservation of attributes of persistent objects when modifications are made thereto, and more specifically, to preserving attributes of the objects when a file including the objects is opened within an environment different than that in which the file was originally created.
As a general rule, new versions of software add functions and attributes to objects in the software that were not found in previous versions. Because of differences between successive versions of a program related to implementing new functionality, problems can arise when a document or file created under a newer version of a software program is subsequently opened, executed, and/or revised, and then saved by an older version of the software. For example, Microsoft Corporation""s WORD(trademark) version 7 word processing program includes a feature in which Internet (or intranet) links are automatically recognized so that the corresponding site/page is readily accessed in a browser program that is activated when the link is selected (i.e., by double clicking a mouse or other pointing device while the cursor controlled by the device is over the link). To clearly differentiate such links from normal text, they are typically displayed using a blue font. Any document that includes such a link, when opened in an earlier version of the WORD(trademark) word processing program, will also display the link in the blue font, but the older version of WORD(trademark) will not provide the underlying hypertext link to the site referenced by the link and is not able to automatically cause a browser to open up the page referenced by the link. Moreover, if the document that originally included the link was created in version 7 of WORD(trademark) is opened and saved in an earlier version of the word processing program, a hypertext link will no longer be associated with blue font text that references the site if the saved document is subsequently opened in version 7 of the word processing program. In other words, since the older version of the word processing program is not equipped to recognize the hypertext association originally included in the document, the software does not preserve the hypertext association in the document when saving it. The new or added functionality associated with objects in the document is thus lost as a result of the document being opened and saved by the earlier version of the word processing program.
A related problem arises when a hypertext markup language (HTML) document created in a conventional text editor is subsequently imported into, for example, Microsoft Corporation""s FrontPage(trademark) software application, which includes an HTML editor. This HTML editor is of the xe2x80x9cwhat you see is what you getxe2x80x9d (WYSIWYG) type, which greatly facilitates developing the desired look and feel of a web page, compared to simple text editors. (Notexe2x80x94the discussion of HTML documents that follows herein and in the claims is intended to encompass extended markup language (XML) documents as well.) Earlier versions of FrontPage(trademark) have not made any attempt to preserve the stylistic formatting of an HTML document applied by the user in a text editor, when the document was opened within the HTML editor and then saved, but have simply applied a generally predefined style that is hard coded into the HTML editor, when saving any HTML document. Thus, the original formatting layout, indent levels, whitespace, and other stylistic attributes of objects provided by a user to a document when it was originally created and saved with a text editor, were lost by opening the document to make any change within the FrontPage(trademark) HTML editor environment. Simply saving the document after it was opened in the FrontPage(trademark) editor caused these stylistic and layout attributes to be lost.
One of the reasons that the formatting style of an HTML document has not previously been preserved under these circumstances is that an HTML editor usually transforms such a document into a substantially different representation internally, because the internal representation more effectively models how a web browser will display a web page defined by an HTML document. Particularly after changes to an imported HTML document have been made in an HTML editor, it becomes substantially more difficult to regenerate format and style (whitespace) of the original HTML document. However, people who create HTML documents often have strong opinions about retaining the style that they have applied to these documents. Users often believe that their style lends an HTML document readability; further, they may desire to retain a consistent look to all of the HTML documents that they create, based on their preferences. It is not surprising that many users of prior art HTML editing programs such as earlier versions of FrontPage(trademark) have been unhappy about the loss of their preferred formatting style and layout in an HTML document when the document was opened in the HTML editor and then saved.
Of even greater concern than possible loss of a preferred formatting is that changes made by previous versions of FrontPage(trademark) to the whitespace and layout of an HTML document imported into the HTML editor can actually break the functionality of scripts and cascading style sheets on a page. The result is that simply by opening and re-saving the page (or by editing it in the xe2x80x9cwysiwygxe2x80x9d view of the program), the page is so changed that scripts may not function and the formatting and layout of tables is possibly changed.
Ideally, an HTML document created in one environment that is imported into another environment, such as an HTML editor, should preserve the document""s original formatting, including both the text and layout style (whitespace) around objects, as much as possible. Importing an HTML document into an editor should not cause any loss of functionality or loss of formatting in tables. Furthermore, the HTML editor should determine the formatting style employed in an imported HTML document created in a different environment so that the style may be applied to changes made to the document within the HTML editor and to newly added objects. Clearly, if a user has simply opened an HTML document within the HTML editor and saved it without making any changes, additions, or deletions, the exact formatting style and text of the original document should be retained. It would also be desirable to enable the user to compare the original version of the HTML document with the version that is saved, after changes, deletions, or additions have been made by the HTML editor. This comparison might be made using any of various types of document comparison tools available from other sources, so that the user can see the changes made as a result of editing the HTML document.
The prior art does not provide a fully satisfactory solution to these problems. Macromedia""s DREAMWEAVER(trademark) software includes an HTML editor that preserves much of the whitespace in an imported HTML document that has been opened and then saved. However, once a structure or region in an imported HTML document is edited in the DREAMWEAVER HTML editor, the whitespace is reformatted to conform to an internally predetermined style that is part of the software program. Furthermore, if text is added to an imported HTML document open in the DREAMWEAVER(trademark) HTML editor, the indent level of the existing surrounding text is not applied to the newly added text. When a copy/paste occurs in an open document, i.e., when formatted text is copied and then pasted into a different part of an HTML document, all surrounding whitespace related to the copied text is lost in the region in which the text is pasted. In addition, this HTML editor does not appear to support the preservation of misnested tags. Tags are misnested if the order in which they are opened is not the same as the (reverse) order in which they are closed. For example, the tag  less than b greater than  less than u greater than hello less than /b greater than  less than /u greater than  is misnestedxe2x80x94it should be  less than b greater than  less than u greater than hello less than /u greater than  less than /b greater than . For some tags, the effect of misnesting a tag is innocuous (however, it depends upon on the browser in which the HTML document with a misnested tag is opened). In other cases, the effect is much more serious because the misnesting causes a significant unintended result. For example, in the tag:  less than table greater than  less than tr greater than  less than td greater than inside less than /tr greater than outside less than /td greater than  less than /table greater than , the  less than /td greater than  end tag is invalid, because it is outside of the  less than tr greater than  tag in which the  less than td greater than  was opened.
Another prior art editor, which is used for more general program development applicable to a multi-tier architecture, appears in Microsoft Corporation""s VISUAL INTERDEV(trademark), version 6.0 software. This editor attempts to preserve certain attributes of specific objects in an imported text file. Whitespace in a text file that is opened in the editor and saved without changes is preserved; but, if changes are made in the file, tags may be modified, attribute value case is not preserved, attribute ordering is not preserved, and whitespace is not preserved. In addition, whitespace surrounding plain text is not preserved. Entities that may appear in the text, e.g., representation of printable characters in a form such as xe2x80x9cand#97xe2x80x9d, are generated when needed, but only in one preferred form, not necessarily in the form employed by the user in an imported file created in a different environment. It would be preferable to preserve the form used in an imported text file and to employ the same type or form for representing any new entities added to a document or file.
As will be apparent from the initial discussion relating to the problems that arise due to differences in attributes employed in different versions of a word processing program, these problems are not limited to imported HTML documents opened in an HTML editor. More generally, these problems can arise when files that include objects having associated attributes in one system are opened in another system or software environment. For example, in a programming environment, the class of an object should persist, even though class descriptions change in a different environment/version of the programming language. This point is illustrated by the following. Assume that a software system includes an object named xe2x80x9cCEmployee.xe2x80x9d This object has the following class definition:
After the software system enables input data on employees to be printed, it is usually desirable to enable the data to be saved for future use. When making the CEmployee object persistent, most software systems use an algorithm like:
The software will invoke these output routines repeatedly, once for each employee object to be stored, resulting in an output stream that looks like:
where * represents a marker the software recognizes as separating the data values and + represents a marker the software recognizes as separating each object.
The software reads the code with an algorithm such as:
However, a later version of the software may extend the CEmployee class by adding the attribute xe2x80x9cManagerxe2x80x9d:
The above definitions of Store and Read will also be extended in the new version of the software in a way that will be apparent to those of ordinary skill in the art. After use with the new version of the software system, the persistent data will appear as:
But, when these data are presented to the old software system, which is not programmed to deal with the new Manager data attribute, the old software system will either fail, because it expects the + object separator, or it will skip over the unexpected data attributes to the + separator. In any case, the Manager data attribute will be discarded and thus will not be available when the data are again loaded into the new version of the software in which Manager and the * separator are understood.
From the preceding discussion, it will be apparent that the prior art does not provide a complete solution to preserving formatting, layout, and attributes in a document within different environments or systems. Accordingly, there is a need for a method that addresses this problem, by preserving formatting and other attributes of objects in a document or other file that is created in one environment, but opened and saved in a different environment. Also, when changes are made to such a document in the different environment, it is preferable that these changes substantially conform to a style that is derived from that of the original document or file.
In accord with the present invention, a method is defined for preserving attributes of a persistent object stream in a file that includes at least one object when the file is opened in a different environment than that in which the file was originally created. The method includes the step of creating a copy of attributes associated with each object when reading the file in the different environment. These attributes include any that are unknown to the different environment, and these attributes associated with each object that are unknown to the different environment are ignored. When writing the file, known attributes associated with each object that are changed in the different environment are merged with the copy of the attributes associated with the object, including any attributes that are unknown in the different environment.
Objects in the file may include text entries having whitespace attributes. A whitespace attribute that is associated with a text entry is preserved in the copy unless changed while the file is open in the different environment. Also, objects in the file may include tag entries having whitespace attributes, and a whitespace attribute associated with a tag entry is preserved in the copy unless changed while the file is open in the different environment. Objects in any class that is unknown in the different environment are preserved in the copy and are ignored in the different environment, but are merged with known objects when the file is written.
In one embodiment, attributes for an object that is unknown to the different environment include a function associated with the object that is not recognized in the different environment, but is recognized in the environment in which the object was first added to the file.
The method also can include the step of parsing the file to identify the persistent object stream. A different internal representation of the attributes associated with objects in the file is employed in the copy that is created. Attributes from the persistent object stream are determined when the file is opened. These attributes are then associated with any related new objects that are added to the file while the file is open, so that attributes of the related new objects are consistent with the persistent object stream. In any case, it is generally preferable to minimize changes to attributes associated with the object in the file when it is saved.
Another aspect of the present invention is directed to a computer-readable medium having computer-executable instructions for performing the steps initially discussed above.
Yet another aspect is directed to a system that includes a memory in which data and machine instructions are stored, a display on which graphics and text are presented to a user, a processor that is coupled to the memory and executes the machine instructions, and a user input device adapted to enable the user to input data and to control the processor. When executed by the processor, the machine instructions cause the processor to implement functions that are generally consistent with the steps of the method set forth above.